let sidebar; function stickyActive(){ // sidebar = document.querySelector(".sticky-side-bar"); let x = window.matchMedia('(min-width:1024px) and (max-width: 1280px)'); if(!sidebar.classList.contains('active') && (!window.matchMedia('(min-width:1024px) and (max-width: 1280px)').matches)){ sidebar.classList.toggle("active"); } } document.addEventListener("DOMContentLoaded", function(){ sidebar = document.querySelector(".sticky-side-bar"); if(document.querySelector(".sticky-menu-button")){ sidebarClose = document.querySelector(".sticky-menu-button"); // sidebarInner = document.querySelector(".sticky-side-bar-inner"); sidebarClose.addEventListener("click", function(){ sidebar.classList.toggle("active"); }) } document.querySelectorAll(".sticky-side-bar-inner a").forEach((menuItem, Index)=>{ menuItem.addEventListener("click", function(e){ e.preventDefault(); const href = this.getAttribute("href"); const offsetTop = document.querySelector(href).offsetTop - 50; scroll({ top: offsetTop, behavior: "smooth" }); }) }) document.querySelectorAll(".scroll-link").forEach((menuItem, Index)=>{ menuItem.addEventListener("click", function(e){ e.preventDefault(); const href = this.getAttribute("href"); const offsetTop = document.querySelector(href).offsetTop - 50; scroll({ top: offsetTop, behavior: "smooth" }); }) }) }); // window.addEventListener("resize", function(){ // // x = window.matchMedia("(max-width: 1024px)"); // stickyActive(); // }); window.onscroll = function() { if(document.querySelector(".sticky-side-bar")){ if(document.documentElement.scrollTop > 250){ document.querySelector(".sticky-side-bar").classList.add('active'); } else { document.querySelector(".sticky-side-bar").classList.remove('active'); } } if(document.querySelector(".bottom-popup")){ let bottomPopup = document.querySelector(".bottom-popup"); let section = document.querySelectorAll(bottomPopup.getElementsByTagName('a')[0].getAttribute("href"))[0].getBoundingClientRect().top; if(document.documentElement.scrollTop > 300 && ((section - 300) > 0)){ bottomPopup.style.bottom = '0'; } else { bottomPopup.style.bottom = '-200px'; } } };